package com.jiyun.login.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiyun.login.feign.*;
import com.jiyun.pojo.*;
import com.jiyun.vo.CatalogDto;
import com.jiyun.vo.CourseDto;
import com.jiyun.vo.ResultResopnse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("consumer")
public class ConsumerController {
    @Autowired
    FeignConsumerService feignConsumerService;
    @Autowired
    FeignTrainService feignTrainService;
    @Autowired
    FeignRaceService feignRaceService;
    @Autowired
    FeignCourseService feignCourseService;
    @Autowired
    FeignLabelService feignLabelService;

//    @RequestMapping("login")
//    public MyResult login(@RequestBody User user){
//        return userService.login(user);
//    }
    @RequestMapping("login")
    public Result login(@RequestBody Consumer consumer){
        return feignConsumerService.login(consumer);
    }
    //    我的课程
    @RequestMapping("courseCount")
    public Result courseCount(Integer consumerId) {
        return feignTrainService.courseCount(consumerId);
    }
    //     我的培训
    @RequestMapping("trainCount")
    public Result trainCount(Integer consumerId) {
        return feignTrainService.trainCount(consumerId);
    }
    //    我的竞赛
    @RequestMapping("raceCount")
    public Result raceCount(Integer consumerId) {
        return feignRaceService.raceCount(consumerId);
    }
    //    我的课程
    @RequestMapping("findAllOne")
    public Result findAllOne() {
        return feignCourseService.findAllOne();
    }
    //   点赞
    @RequestMapping("dianzan")
    public Result dianzan(@RequestParam Integer id,@RequestParam Integer consumerId) {
        return feignCourseService.dianzan(id,consumerId);
    }
    //    最新课程
    @RequestMapping("findAllDate")
    public Result findAllDate() {
        return feignCourseService.findAllDate();
    }
    //    最新培训
    @RequestMapping("findAllTime")
    public Result findAllTime() {
        return feignTrainService.findAllTime();
    }
    @RequestMapping("findByCId")
    public Result findById(@RequestParam Integer consumerId){
        return feignTrainService.findByCId(consumerId);
    }
    @RequestMapping("findAll")
    public Result findAll(@RequestParam String aaa,@RequestParam String lib){
        return feignCourseService.findAll(aaa,lib);
    }
    @RequestMapping("findLabelAll")
    public ResultResopnse findLabelAll(){
        return feignLabelService.findAll();
    }
    //  查询所有课程
    @RequestMapping("findCatalog")
    public ResultResopnse findCatalog(@RequestBody CatalogDto catalogDto) {
        return feignCourseService.findCatalog(catalogDto);
    }
    //学习
    @RequestMapping("xuexi")
    public Result xuexi(@RequestParam Integer catalogId, @RequestParam Integer consumerId,@RequestParam Integer courseId){
        return feignCourseService.xuexi(catalogId,consumerId,courseId);
    }
    //查看用户学过哪些书了
    @RequestMapping("consumerFindAll1")
    public Result consumerFindAll1(@RequestParam Integer consumerId,@RequestParam Integer courseId){
        return feignCourseService.consumerFindAll1(consumerId,courseId);
    }
    //查看用户学过哪些书了
    @RequestMapping("catalogFindAll1")
    public Result catalogFindAll1(){
        return feignCourseService.catalogFindAll1();
    }
    @RequestMapping("findPage")
    public Page<CourseDto> findPage(@RequestBody CourseDto courseDto){
        return feignCourseService.findPage(courseDto);
    };

//    查询所有竞赛
    @RequestMapping("findRaceAll")
    public Result findRaceAll(@RequestBody RaceVo raceVo){
        return feignRaceService.findRaceAll(raceVo);
    }
    @RequestMapping("findLikeRace")
    public Result findLikeRace(@RequestParam String aaa,@RequestParam String lib){
        return feignRaceService.findLikeRace(aaa,lib);
    }

//    添加
    @RequestMapping("addTeam")
    public void addTeam(@RequestBody Race race){
       feignRaceService.addTeam(race);
    };

//    查询所有战队
    @RequestMapping("findTeam")
    public List<Team>findTeam(){
        return feignRaceService.findTeam();
    }
    @RequestMapping("findTrainId")
    public Result findTrainId(@RequestParam Integer id){
       return feignRaceService.findTrainId(id);
    }

}
